/*
 * File:   path.h
 * Author: dolphinigle
 *
 * Created on December 1, 2011, 2:29 PM
 */

#ifndef PATH_H
#define	PATH_H

#include <cstdio>
#include <cstdlib>
#include <string>
#include <cassert>

using std::string;

// Describes a path in real disk or virtual disk
// For example, @/home/dolphinigle is in real disk and is represented by:
// p.path() == "/home/dolphinigle"
// p.is_virtual() == false

// On the other hand, /pc/virtual is in virtual disk and is represented by:
// p.path() == "/pc/virtual"
// p.is_virtual() == true

// If the first character is not "/" (for example, doc/aaa), then the path is
// RELATIVE to current directory. Otherwise, it's ABSOLUTE.

// Copyable, assignable
class Path {
public:
  Path(const string& path, bool is_virtual)
      : path_(path), is_virtual_(is_virtual) {}
  Path(const string& raw_path);
  string path() const { return path_; }
  bool is_virtual() const { return is_virtual_; }
  string ToString() const {
    if (is_virtual_) return path_;
    return "@" + path_;
  }

  Path(const Path& path) {
    path_ = path.path_;
    is_virtual_ = path.is_virtual_;
  }
  bool operator=(const Path& path) {
    path_ = path.path_;
    is_virtual_ = path.is_virtual_;
  }
private:

  string path_;
  bool is_virtual_;
};

#endif	/* PATH_H */

